package com.xintouyun.medicine.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xintouyun.medicine.entity.User;
import com.xintouyun.medicine.service.UserService;
import com.xintouyun.medicine.service.impl.UserServiceImpl;

@WebServlet("/UserCheckServlet")
public class UserCheckServlet extends HttpServlet{

	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		PrintWriter out = response.getWriter();
		
		String nickname = request.getParameter("ucs");
		UserService userService = new UserServiceImpl();
		User user = userService.getUser(nickname);
		
		if(user != null) {		
			out.println("F");
		}else {
			out.print("T");
		}
		out.close();
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}
}
